﻿using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Sustainalytics.Reporting.BusinessLogic
{
    public class ReportsRepository
    {
        private string connectionString = "mongodb://localhost:27017/Reports";

        public ReportsRepository()
        {
 
        }

        public async Task SaveControversiesReportSection(ControversiesReportSection reportSection, CancellationToken cancellationToken)
        {
            //var dbCtx = new ReportsDbContext();

            //var filter = Builders<ControversiesReportSection>.Filter.Eq("_id", reportSection.Id);

            //var options = new FindOneAndReplaceOptions<ControversiesReportSection>() { IsUpsert = true };

            //var result = await dbCtx.ControversiesReportSections.FindOneAndReplaceAsync(filter, reportSection, options, cancellationToken);

            var repository = new RepositoryCollectionAsync<ControversiesReportSection>(connectionString);

            await repository.Save(reportSection, reportSection.Id, cancellationToken);

        }


    }
}
